package com.canaan.business.controller.pc.bill;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.canaan.common.annotation.Log;
import com.canaan.common.core.controller.BaseController;
import com.canaan.common.core.domain.AjaxResult;
import com.canaan.common.enums.BusinessType;
import javax.annotation.Resource;
import com.canaan.business.domain.bill.TrayProductFreeze;
import com.canaan.business.service.bill.ITrayProductFreezeService;
import com.canaan.common.utils.poi.ExcelUtil;
import com.canaan.common.core.page.TableDataInfo;

/**
 * 托盘物料冻结Controller
 *
 * @author canaan
 * @date 2025-04-21
 */
@Api(tags = "托盘物料冻结")
@RestController
@RequestMapping("/bill/trayProductFreeze")
public class TrayProductFreezeController extends BaseController {
    @Resource
    private ITrayProductFreezeService trayProductFreezeService;

    /**
     * 查询托盘物料冻结列表
     */
    @ApiOperation(value = "查询托盘物料冻结列表")
    @PreAuthorize("@ss.hasPermi('bill:trayProductFreeze:list')")
    @GetMapping("/list")
    public TableDataInfo list(TrayProductFreeze trayProductFreeze) {
        startPage();
        List<TrayProductFreeze> list = trayProductFreezeService.selectTrayProductFreezeList(trayProductFreeze);
        return getDataTable(list);
    }

    /**
     * 导出托盘物料冻结列表
     */
    @ApiOperation(value = "导出托盘物料冻结列表")
    @PreAuthorize("@ss.hasPermi('bill:trayProductFreeze:export')")
    @Log(title = "托盘物料冻结", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrayProductFreeze trayProductFreeze) {
        List<TrayProductFreeze> list = trayProductFreezeService.selectTrayProductFreezeList(trayProductFreeze);
        ExcelUtil<TrayProductFreeze> util = new ExcelUtil<TrayProductFreeze>(TrayProductFreeze.class);
        util.exportExcel(response, list, "托盘物料冻结数据");
    }

    /**
     * 获取托盘物料冻结详细信息
     */
    @ApiOperation(value = "获取托盘物料冻结详细信息")
    @PreAuthorize("@ss.hasPermi('bill:trayProductFreeze:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(trayProductFreezeService.selectTrayProductFreezeById(id));
    }

    /**
     * 新增托盘物料冻结
     */
    @ApiOperation(value = "新增托盘物料冻结")
    @PreAuthorize("@ss.hasPermi('bill:trayProductFreeze:add')")
    @Log(title = "托盘物料冻结", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrayProductFreeze trayProductFreeze) {
        return toAjax(trayProductFreezeService.insertTrayProductFreeze(trayProductFreeze));
    }

    /**
     * 修改托盘物料冻结
     */
    @ApiOperation(value = "修改托盘物料冻结")
    @PreAuthorize("@ss.hasPermi('bill:trayProductFreeze:edit')")
    @Log(title = "托盘物料冻结", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrayProductFreeze trayProductFreeze) {
        return toAjax(trayProductFreezeService.updateTrayProductFreeze(trayProductFreeze));
    }

    /**
     * 删除托盘物料冻结
     */
    @ApiOperation(value = "删除托盘物料冻结")
    @PreAuthorize("@ss.hasPermi('bill:trayProductFreeze:remove')")
    @Log(title = "托盘物料冻结", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(trayProductFreezeService.deleteTrayProductFreezeByIds(ids));
    }
}
